package com.nftturbocollection.domain.service.impl;

import com.alicp.jetcache.anno.CacheRefresh;
import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nftturbocollection.domain.entity.Collection;
import com.nftturbocollection.domain.service.CollectionService;
import com.nftturbocollection.infrastructure.mapper.CollectionMapper;

import java.util.concurrent.TimeUnit;

/**
 * @author Hollis
 * <p>
 * 通用的藏品服务
 */
public abstract class BaseCollectionService extends ServiceImpl<CollectionMapper, Collection> implements CollectionService {
    @Override
    @Cached(
            name = ":collection:cache:id:",
            expire = 60,
            localExpire = 10,
            timeUnit = TimeUnit.MINUTES,
            cacheType = CacheType.BOTH,
            key = "#collectionId",
            cacheNullValue = true)
    @CacheRefresh(refresh = 50, timeUnit = TimeUnit.MINUTES)
    public Collection queryById(Long collectionId) {
        return getById(collectionId);
    }

}
